package com.zzedu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzedu.common.utils.StringUtils;
import com.zzedu.domain.ZzExerciseBookSubmitContent;
import com.zzedu.dto.StudentExerciseReportDTO;
import com.zzedu.dto.ZzExerciseBookSubmitContentDTO;
import com.zzedu.mapper.ZzExerciseBookSubmitContentMapper;
import com.zzedu.service.IZzExerciseBookSubmitContentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作业内容Service业务层处理
 *
 * @author Mr.Wang
 * @date 2025-06-02
 */
@Service
public class ZzExerciseBookSubmitContentServiceImpl extends ServiceImpl<ZzExerciseBookSubmitContentMapper, ZzExerciseBookSubmitContent> implements IZzExerciseBookSubmitContentService {

    @Override
    public LambdaQueryWrapper<ZzExerciseBookSubmitContent> buildQuery(ZzExerciseBookSubmitContentDTO zzExerciseBookSubmitContent) {
        LambdaQueryWrapper<ZzExerciseBookSubmitContent> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(null != zzExerciseBookSubmitContent.getBookId(), ZzExerciseBookSubmitContent::getBookId, zzExerciseBookSubmitContent.getBookId());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(zzExerciseBookSubmitContent.getSubjectContent()), ZzExerciseBookSubmitContent::getSubjectContent, zzExerciseBookSubmitContent.getSubjectContent());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(zzExerciseBookSubmitContent.getContent()), ZzExerciseBookSubmitContent::getContent, zzExerciseBookSubmitContent.getContent());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(zzExerciseBookSubmitContent.getSubmitContent()), ZzExerciseBookSubmitContent::getSubmitContent, zzExerciseBookSubmitContent.getSubmitContent());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(zzExerciseBookSubmitContent.getCorrectRemark()), ZzExerciseBookSubmitContent::getCorrectRemark, zzExerciseBookSubmitContent.getCorrectRemark());
        lambdaQueryWrapper.eq(null != zzExerciseBookSubmitContent.getGmtCreate(), ZzExerciseBookSubmitContent::getGmtCreate, zzExerciseBookSubmitContent.getGmtCreate());
        lambdaQueryWrapper.eq(null != zzExerciseBookSubmitContent.getGmtModify(), ZzExerciseBookSubmitContent::getGmtModify, zzExerciseBookSubmitContent.getGmtModify());
        lambdaQueryWrapper.eq(null != zzExerciseBookSubmitContent.getDeleted(), ZzExerciseBookSubmitContent::getDeleted, zzExerciseBookSubmitContent.getDeleted());

        lambdaQueryWrapper.orderByDesc(ZzExerciseBookSubmitContent::getId);
        return lambdaQueryWrapper;
    }

    public List<StudentExerciseReportDTO> getStudentExerciseReport(
            Long clazzId,
            Long pictureBookId, List<Long> stuIdList
    ) {
        return baseMapper.getStudentExerciseReport(clazzId, pictureBookId, stuIdList);
    }
}